package model.admin;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import model.gallery.BestWeeklyVO;
import model.member.MemberVO;
import model.util.CommonConstants;
import model.util.ListVO;
import model.util.PagingBean;

public class AdminService {
	private AdminDao adminDao;

	public AdminService(AdminDao adminDao) {
		super();
		this.adminDao = adminDao;
	}

	public AdminService() {
		super();
		// TODO Auto-generated constructor stub
	}
	public void addWeek(BestWeeklyVO vo) throws SQLException{
		adminDao.addWeek(vo);
	}

	public List<BestWeeklyVO> getUpdateList() throws SQLException {
		// TODO Auto-generated method stub
		return adminDao.getUpdateList();
	}

	public ListVO getMemberList(String page) throws SQLException {
		// TODO Auto-generated method stub
		if(page==null||page==""){
			page="1";
		}
		HashMap map = new HashMap();
		map.put("page", page);
		map.put("number", CommonConstants.ADMIN_CONTENT_PER_PAGE);
		
		ArrayList<Object> mList =  adminDao.getMemberList(map);
		int total = adminDao.totalCountUser();
		PagingBean paging=new PagingBean(total,Integer.parseInt(page),CommonConstants.ADMIN_CONTENT_PER_PAGE);
		
		ListVO list=new ListVO(mList,paging);
		
		return list;
	}
	

	public BestWeeklyVO getWeeklyInfo(int week) throws SQLException {
		// TODO Auto-generated method stub
		return adminDao.getWeeklyInfo(week);
	}

	public void updateBest(BestWeeklyVO vo) throws SQLException {
		// TODO Auto-generated method stub
		adminDao.updateBest_P(vo);
		adminDao.updateBest_S(vo);
		adminDao.updateBest_A(vo);
	}

	public void lvChange(int uid, int lv) throws SQLException {
		
		HashMap map = new HashMap();
		map.put("uid", uid);
		map.put("lv", lv);
		
		System.out.println("Service : "+ uid + " " + lv);
		adminDao.lvChange(map);
	}
	

	public void leave(int uId) throws SQLException {
		adminDao.leave(uId);
	}
	public List<MemberVO> findMemberList(String nickName) throws SQLException {
		List<MemberVO> a = adminDao.findMemberList(nickName);
		//System.out.println("service"+a);
		return adminDao.findMemberList(nickName);
		
	}

	public void deleteWeekly(int week) throws SQLException {
		adminDao.deleteWeekly(week);
		
	}

	public void nullset(BestWeeklyVO vo) throws SQLException {
		adminDao.nullset(vo);
		
	}
}
